
/**
 * Project Name:cats-core-impl
 * File Name:MessageServiceImpl.java
 * Package Name:com.catsic.core.message.service.impl
 * Date:2014年2月27日下午1:36:38
 * Copyright (c) 2014, oa.catsic.com All Rights Reserved.
 */
 
package com.catsic.pub.message.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.catsic.base.BaseServiceImpl;
import com.catsic.base.exception.CatsicException;
import com.catsic.pub.condition.MessageCondition;
import com.catsic.pub.constants.Constants;
import com.catsic.pub.entity.Message;
import com.catsic.pub.exception.CatsicExceptionCode;
import com.catsic.pub.message.dao.MessageDao;
import com.catsic.pub.message.service.MessageService;
import com.catsic.pub.specification.MessageSpec;
import com.catsic.pub.status.MessageStatus;


/**
 * ClassName: MessageServiceImpl
 * Description: 系统消息Service实现类
 * date: 2014年2月27日 下午1:36:38
 * author: yangyd
 */
//@Aspect
@Service("messageService")
public class MessageServiceImpl extends BaseServiceImpl<Message, String> 
		implements	MessageService{

	@Autowired
	private MessageDao messageDao;
/*	
	@Override
	protected BaseDao<Message, String> getEntityDao() {
		return messageDao;
	}*/
	
	
	/**
	 * @see com.catsic.pub.message.service.MessageService#sendMessage(java.lang.Long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
	 */
	public Message sendMessage(String acceptObjId,String acceptObjName,String moduleName,String title,String content,String url){
		Message message = new Message();
		return message;
	}
	
	/**
	 * @see com.catsic.core.base.BaseServiceImpl#add(java.lang.Object)
	 */
	@Override
	public Message add(Message message){
		return super.add(message);
	}
	
	/**
	 * @see com.catsic.core.base.BaseServiceImpl#update(java.lang.Object)
	 */
	@Override
	public Message update(String id){
		Message message = findById(id);
		message.setStatus(MessageStatus.已读);
		return super.add(message);
	}
	
	/**
	 * @see com.catsic.pub.message.service.MessageService#findAll(com.catsic.core.conditon.MessageCondition, org.springframework.data.domain.Pageable)
	 */
	public Page<Message> findAll(MessageCondition condition, Pageable pageable){
		MessageSpec spec = new MessageSpec(condition);
		//sendMessage(2L, "2", "2", "2", "2", "2");
		return messageDao.findAll(spec, pageable);
	}
	
	
	/**
	 * @see com.catsic.pub.message.service.MessageService#findById(java.lang.Long)
	 */
	@Override
	public Message findById(String id){
		Message message = getById(id);
		if(null == message){
			throw new CatsicException(CatsicExceptionCode.实体不存在,Constants.MESSAGE);
		}
		return message;
	}
}
